<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>JsBridge测试Demo</title>
  <style type="text/css">
    * {
        margin: 0;
        padding: 0;
    }

    ul > li {
        display: block;
        text-align: center;
        list-style: none;
        background: #ccc;
        margin: 10px;
        padding: 8px;
    }


  </style>
  <script type="text/javascript"
          src="http://res.wx.qq.com/mmbizwap/zh_CN/htmledition/js/vconsole/2.5.1/vconsole.min.js"></script>
</head>
<body>
<ul id="ul">
  <li>Map To String</li>
  <li>Complex data</li>
  <li>Test Return</li>
  <li>Get Version</li>
</ul>
<ul>
  <li><a href='javascript:window.native.loadNewPage("http://www.baidu.com");'>Load New Page</a></li>
</ul>

<script type="text/javascript">

    var ul = document.getElementById("ul");
    var li = ul.getElementsByTagName("li");
    for (var i = 0; i < li.length; i++) {
        li[i].index = i;
        li[i].onclick = function () {
            switch (this.index) {
                case 0:
                 var ret = window.mapToString({data:{"count":2,"title":[{"name":"nnn","value":"nnnvalue","default_show":1}
        ,{"name":"mmm","value":"mmmvalue\"aasdasd"}]}});
                 alert(ret);
                 break;
                case 1:
                window.service.test([-1111111111111111111, 1.235, 'hello world', true,
        function(args){alert(args)}, {a:100101, b:function(){alert('执行复杂回调函数')}},
        [1,2,3,4]]);
                    break;
                case 2:
                window.service.testReturn(function(array, map){
                console.log(array);
                console.log(map);
        });
                    break;
                case 3:
                    var version = window.getVersion();
                    console.log(version, typeof version);
                    break;
            }
        }
    }

    function test(){
        var myDate = new Date();
        var datestr = myDate.toLocaleDateString();
        console.log(datestr);
        return datestr;
    }

    window.onload = function() {
        window.startTime = new Date().getTime();
        console.log(startTime)
    }

    window.onJsBridgeReady = function () {
        console.log("onJsBridgeReady load finish, cost:" + (new Date().getTime() - window.startTime) + "ms");
    }

</script>
</body>
</html>